package com.zhou.review3.serviceImpl;

import com.zhou.review3.entity.User;
import com.zhou.review3.mapper.UserMapper;
import com.zhou.review3.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collection;
import java.util.List;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;



    public List<User> findAllUsers() {
        return userMapper.queryAll();
    }


    public int removeUser(int id) {
        return userMapper.deleteByPrimaryKey(id);
    }


    public void addUser(User user) {
        userMapper.insert(user);
    }


    public User findUser(int id) {
        return userMapper.selectByPrimaryKey(id);
    }


    public void modifyUser(User newuser) {
        userMapper.updateByPrimaryKey(newuser);
    }

    public boolean login(String username,String password){
        if(userMapper.selectByNameAndPassword(username, password).size()==0)
            return false;
        else
            return true;
    }
}
